﻿<Window x:Class="Microsoft.Samples.Kinect.DepthBasics.DepthSmoothing.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Depth Basics" Height="1024" Width="770" Loaded="WindowLoaded" Closing="WindowClosing">

    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <SolidColorBrush x:Key="MediumGreyBrush" Color="#ff6e6e6e"/>
        <SolidColorBrush x:Key="KinectPurpleBrush" Color="#ff52318f"/>
        <SolidColorBrush x:Key="KinectBlueBrush" Color="#ff00BCF2"/>
        <Style TargetType="{x:Type Image}">
            <Setter Property="SnapsToDevicePixels" Value="True"/>
        </Style>
        <Style TargetType="{x:Type Button}" x:Key="SnapshotButton" >
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <StackPanel Orientation="Horizontal" Background="Transparent">
                                <TextBlock x:Name="SnapText" Text="{TemplateBinding Content}" TextAlignment="Left"  VerticalAlignment="Center" Foreground="{StaticResource KinectPurpleBrush}" FontSize="15" />
                                <Grid Margin="9,0,0,0">
                                    <Image x:Name="SnapNormal" Source="Images\SnapNormal.png" Stretch="None" HorizontalAlignment="Center"/>
                                    <Image x:Name="SnapHover" Source="Images\SnapHover.png" Stretch="None" HorizontalAlignment="Center" Visibility="Collapsed"/>
                                </Grid>
                            </StackPanel>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Visibility" Value="Collapsed" TargetName="SnapNormal"/>
                                <Setter Property="Visibility" Value="Visible" TargetName="SnapHover"/>
                                <Setter Property="Foreground" Value="{StaticResource KinectBlueBrush}" TargetName="SnapText"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="{x:Type CheckBox}" x:Key="SquareCheckBox" >
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type CheckBox}">
                        <Grid>
                            <StackPanel Orientation="Horizontal" Background="Transparent">
                                <Grid x:Name="SquareCheckBoxChecked">
                                    <Image x:Name="CheckedNormal" Source="Images\CheckedNormal.png" Stretch="None" HorizontalAlignment="Center"/>
                                    <Image x:Name="CheckedHover" Source="Images\CheckedHover.png" Stretch="None" HorizontalAlignment="Center" Visibility="Collapsed"/>
                                </Grid>
                                <Grid x:Name="SquareCheckBoxUnchecked" Visibility="Collapsed">
                                    <Image x:Name="UncheckedNormal" Source="Images\UncheckedNormal.png" Stretch="None" HorizontalAlignment="Center"/>
                                    <Image x:Name="UncheckedHover" Source="Images\UncheckedHover.png" Stretch="None" HorizontalAlignment="Center" Visibility="Collapsed"/>
                                </Grid>
                                <TextBlock x:Name="SquareCheckBoxText" Text="{TemplateBinding Content}" TextAlignment="Left"  VerticalAlignment="Center" Foreground="{StaticResource KinectPurpleBrush}" FontSize="15"  Margin="9,0,0,0"/>                          
                            </StackPanel>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="false">
                                <Setter Property="Visibility" Value="Collapsed" TargetName="SquareCheckBoxChecked"/>
                                <Setter Property="Visibility" Value="Visible" TargetName="SquareCheckBoxUnchecked"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Visibility" Value="Collapsed" TargetName="CheckedNormal"/>
                                <Setter Property="Visibility" Value="Collapsed" TargetName="UncheckedNormal"/>
                                <Setter Property="Visibility" Value="Visible" TargetName="CheckedHover"/>
                                <Setter Property="Visibility" Value="Visible" TargetName="UncheckedHover"/>
                                <Setter Property="Foreground" Value="{StaticResource KinectBlueBrush}" TargetName="SquareCheckBoxText"/>
                            </Trigger>
                       </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>        
    </Window.Resources>

    <Grid Name="layoutGrid" Margin="10 0 10 0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <DockPanel Grid.Row="0" Margin="0 0 0 20">
            <Image DockPanel.Dock="Left" Source="Images\Logo.png" Stretch="Fill" Height="32" Width="81" Margin="0 10 0 5"/>
            <TextBlock DockPanel.Dock="Right" Margin="0 0 -1 0" VerticalAlignment="Bottom" Foreground="{StaticResource MediumGreyBrush}" FontFamily="Segoe UI" FontSize="18">Depth Basics</TextBlock>
            <Image Grid.Column="1" Source="Images\Status.png" Stretch="None" HorizontalAlignment="Center" Margin="0 0 0 5"/>
        </DockPanel>
        <Viewbox Grid.Row="1" Stretch="Uniform" HorizontalAlignment="Center">
            <Image Name="Image" Width="640" Height="480"/>
        </Viewbox>
        <Button Grid.Row="2" Style="{StaticResource SnapshotButton}" Content="Screenshot" Height="Auto" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10 10 0 10" Name="buttonScreenshot"  Click="ButtonScreenshotClick" />
        <CheckBox Grid.Row="2" Style="{StaticResource SquareCheckBox}" Content="Near Mode" Height="Auto" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 10 10 10" Name="checkBoxNearMode" Checked="CheckBoxNearModeChanged" Unchecked="CheckBoxNearModeChanged"/>
        
        
        <StackPanel Grid.Row="3">
            <CheckBox Style="{StaticResource SquareCheckBox}" Content="Use Filtering" Height="Auto" HorizontalAlignment="Left" VerticalAlignment="Center" Name="checkBoxUseFiltering" Checked="CheckBoxUseFilteringChanged" Unchecked="CheckBoxUseFilteringChanged"/>
            <TextBlock 
                Text="Inner Band Threshold: (lower numbers are smoother)" 
                Margin="5,0,0,0"
                Visibility="{Binding ElementName=checkBoxUseFiltering, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"/>

            <Slider Name="SliderInnerBand"
                    Value="2"
                    Interval="1"
                    Minimum="1"
                    Maximum="8" 
                    IsSnapToTickEnabled="True"
                    ValueChanged="SliderInnerBand_ValueChanged" 
                    Visibility="{Binding ElementName=checkBoxUseFiltering, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"/>

            <TextBlock 
                Text="{Binding ElementName=SliderInnerBand, Path=Value}" 
                HorizontalAlignment="Center"
                Visibility="{Binding ElementName=checkBoxUseFiltering, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"/>

            <TextBlock 
                Text="Outer Band Threshold: (lower numbers are smoother)" 
                Margin="5,0,0,0"
                Visibility="{Binding ElementName=checkBoxUseFiltering, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"/>

            <Slider Name="SliderOuterBand"
                    Value="5"
                    Interval="1"
                    Minimum="1"
                    Maximum="16" 
                    IsSnapToTickEnabled="True"
                    ValueChanged="SliderOuterBand_ValueChanged"
                    Visibility="{Binding ElementName=checkBoxUseFiltering, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"/>

            <TextBlock 
                Text="{Binding ElementName=SliderOuterBand, Path=Value}" 
                HorizontalAlignment="Center"
                Visibility="{Binding ElementName=checkBoxUseFiltering, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"/>

            <CheckBox Style="{StaticResource SquareCheckBox}" Content="Use Average" Height="Auto" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 10 0 0" Name="checkBoxUseAverage" Checked="CheckBoxUseAverageChanged" Unchecked="CheckBoxUseAverageChanged"/>


            <TextBlock 
                Text="Number of frames to average:" 
                Margin="5,0,0,0"
                Visibility="{Binding ElementName=checkBoxUseAverage, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"/>

            <Slider Name="SliderAverage"
                    Value="4"
                    Interval="1"
                    Minimum="2"
                    Maximum="12"
                    IsSnapToTickEnabled="True"
                    Visibility="{Binding ElementName=checkBoxUseAverage, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}" ValueChanged="SliderAverage_ValueChanged" />

            <TextBlock 
                Text="{Binding ElementName=SliderAverage, Path=Value}" 
                HorizontalAlignment="Center" 
                Visibility="{Binding ElementName=checkBoxUseAverage, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"/>

        </StackPanel>

        <StatusBar Grid.Row="5" HorizontalAlignment="Stretch" Name="statusBar" VerticalAlignment="Bottom" Background="White" Foreground="{StaticResource MediumGreyBrush}">
            <StatusBarItem Padding="0 0 0 10">
                <TextBlock Name="statusBarText" Margin="-1 0 0 0">Press 'Screenshot' to save a screenshot to your 'My Pictures' directory.</TextBlock>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Window>
